postgres:
	docker run --name my_postgres -p 5432:5432 -e POSTGRES_USER=root -e POSTGRES_PASSWORD=aa8123558 -d postgres:12-alpine

createdb:
	docker exec my_postgres createdb --username=root --owner=root GoBank

dropdb:
	docker exec my_postgres dropdb --username=root GoBank

migrateup:
	migrate -path db/migration -database "postgresql://root:aa8123558@localhost:5432/GoBank?sslmode=disable" -verbose up

migrateup:
	migrate -path db/migration -database "postgresql://root:aa8123558@localhost:5432/GoBank?sslmode=disable" -verbose up 1

migratedown:
	migrate -path db/migration -database "postgresql://root:aa8123558@localhost:5432/GoBank?sslmode=disable" -verbose down

migratedown1:
	migrate -path db/migration -database "postgresql://root:aa8123558@localhost:5432/GoBank?sslmode=disable" -verbose down 1

sqlc:
	sqlc generate

test:
	go test -v -cover ./...

server:
	go run main.go

db_docs:
	dbdocs build doc/db.dbml

db_schema:
	dbml2sql --postgres -o doc/schema.sql doc/db.dbml 

mock:
	mockgen -package mockdb -destination db/mock/store.go GoBank/db/sqlc Store

proto:
	protoc --proto_path=proto --go_out=pb --go_opt=paths=source_relative --go-grpc_out=pb --go-grpc_opt=paths=source_relative --grpc-gateway_out=pb --grpc-gateway_opt=paths=source_relative proto/*.proto

evans:
	evans --host localhost --port 9090 -r repl

.PHONY: postgres createdb dropdb migrateup migratedown sqlc test mock migratedown1 migrateup1 db_docs db_schema proto evans